﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SGRapidForm.Foundation.Service.Interface;
using SGRapidForm.Foundation.Entity;
using SGRapidForm.Foundation.Component;

namespace SGRapidForm.Foundation.Service
{
    public partial class FoundationService : IFoundationService
    {
        private AreaComponet areaComponet;
        public AreaComponet AreaComponet
        {
            get
            {
                if (areaComponet == null)
                {
                    this.areaComponet = new AreaComponet();
                }
                return this.areaComponet;
            }
            set { areaComponet = value; }
        }
        
        /// <summary>
        /// 查询所有的地区记录
        /// </summary>
        /// <returns>所有地区记录的集合</returns>
        public List<AreaEntity> GetAreaAll()
        {
            return this.AreaComponet.GetAreaList();
        }
        /// <summary>
        /// 进行过滤、排序、分页查询地区记录数
        /// </summary>
        /// <param name="filterConditions">过滤条件</param>
        /// <returns>记录数</returns>
        public int GetAreaPageCount(string filterConditions)
        {
            return this.AreaComponet.GetAreaCount(filterConditions);
        }
        /// <summary>
        /// 进行过滤、排序、分页查询地区
        /// </summary>
        /// <param name="startRecord">开始记录索引</param>
        /// <param name="maxRecords">每页记录数</param>
        /// <param name="sortColumns">排序列</param>
        /// <param name="filterConditions">过滤条件SQL</param>
        /// <returns>地区集合</returns>
        public List<AreaEntity> GetAreaPage(Int32 startRecord, Int32 maxRecords, String sortColumns, String filterConditions)
        {
            return this.AreaComponet.PagingGetArea(startRecord, maxRecords, sortColumns, filterConditions);
        }

        /// <summary>
        /// 添加一条记录
        /// </summary>
        /// <returns>是否添加成功</returns>
        public bool AddArea(AreaEntity areaDetails)
        {
            return this.AreaComponet.Add(areaDetails);
        }
        /// <summary>
        /// 根据keyid来获取一条记录信息
        /// </summary>
        /// <param name="keyid">一个记录的keyid</param>
        /// <returns>返回记录的所有信息</returns>
        public AreaEntity GetAreaByKeyid(string keyid)
        {
            return this.AreaComponet.GetAreaByKeyid(keyid);
        }
        /// <summary>
        /// 更新一条地区维护记录
        /// </summary>
        /// <param name="UserDetails">一条记录</param>
        /// <returns>是否更新成功</returns>
        public bool UpdateArea(AreaEntity areaEntity)
        {
            return this.AreaComponet.UpdateArea(areaEntity);
        }
        /// <summary>
        /// 根据keyid来删除一条记录
        /// </summary>
        /// <param name="keyid">一条记录keyid</param>
        /// <returns>是否删除成功</returns>
        public bool DeleteArea(string keyid)
        {
            return this.AreaComponet.DeleteArea(keyid);
        }

        public bool DeleteAreaAndParentkeyid(string keyid)
        {
            return this.AreaComponet.DeleteAreaAndParentKeyid(keyid);
        }
        /// <summary>
        /// 根据过滤条件查询
        /// </summary>
        /// <param name="filterConditions">条件值</param>
        /// <returns>查询的集合</returns>
        public List<AreaEntity> DoSelectByArea(string fieldconditions)
        {
            return this.AreaComponet.DoSelectByArea(fieldconditions);
        }
    }
}
